package com.StarStudio.Utils;

import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.Entity.PageSupport;
import com.ruoyi.common.core.Entity.QueryPageBean;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.sql.SqlUtil;

public class QueryPageUtils extends PageHelper {
    //改写startPage
    public static void startPage() {
        QueryPageBean queryPageBean = PageSupport.buildPageRequest();
        Integer pageNum = queryPageBean.getPageNum();
        Integer pageSize = queryPageBean.getPageSize();
        if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
            String orderBy = SqlUtil.escapeOrderBySql(queryPageBean.getOrderBy());
            Boolean reasonable = queryPageBean.getReasonable();
            PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
        }
    }
}
